1. Field of the Invention
The present invention relates to an image processing apparatus, an image processing method, and a computer program product.
2. Description of the Related Art
Various methods for extracting a ruled line from an image have been proposed; for example, Japanese Patent No. 3215163 discloses a method of determining a ruled line based on an aspect ratio of a long black line image in horizontal and vertical directions of a binary image by performing rectangle extraction, selecting a table area candidate, and extracting the long black line image in the horizontal and vertical directions as a ruled line.
Furthermore, Japanese Patent No. 3344774 discloses a method of discriminating a separator from an underline by extracting a long black line image in a horizontal direction of a binary image as a ruled line.
In addition, Japanese Patent Application Laid-open No. 2002-133426 discloses a method of extracting a ruled line from a multi-value image, which reduces over-extraction of a ruled line. Specifically, a false ruled line is excluded using an average value of a ratio of gradients of an outline of a ruled line in a tangential direction and a normal direction. Ruled lines extracted by this method can be used for spreadsheet processing or character recognition processing.
Moreover, Japanese Patent Application Laid-open No. 2005-348279 discloses an image forming apparatus applicable to compression of a multi-value image, in which characters and extracted ruled lines are compressed such that the characters and the ruled lines are expressed in monochrome, in which areas corresponding to a background and a picture are compressed at low resolution while maintaining the number of colors, and in which the characters, the ruled lines, and the areas corresponding to the background and the picture are displayed in a superimposed manner. With this method, an image can be compressed while maintaining a level of visibility of the characters and the ruled lines whose outline portion requires a higher level of visibility and a level of visibility of an area of the photographic picture in which the number of colors needs to be maintained. As is indicated by the above examples, the technology for extracting a ruled line is applicable to various fields.
However, when the above conventional technologies are used for compression of a multi-value image, an excessive extraction of the ruled line (over-extraction) may degrade the image quality. Therefore, a process for preventing the over-extraction is required. The methods disclosed in Japanese Patent No. 3215163 and Japanese Patent No. 3344774 are used for a binary image, and do not include a process for preventing the over-extraction that may be caused in a multi-value image.
The method disclosed in Japanese Patent Application No. 2002-133426 includes a process for preventing the over-extraction from a multi-value image. However, when extracting an inclined ruled line, gradients in a tangential direction and a normal direction of a ruled line needs to be obtained, which requires a large number of arithmetic operations. The process is explained briefly with reference to FIG. 9.
FIG. 9 is a schematic diagram for explaining a disadvantage of the conventional method of extracting a ruled line from a multi-value image. As shown in FIG. 9, an outline pixel 46 is a reference point, and a pixel 44 that is “d” pixels away from the outline pixel 46 in a normal direction 43 is used as a pixel necessary for obtaining a gradient θ in the normal direction 43. If a ruled line 40 extends horizontally (without inclination), a pixel that is “d” pixels away from the outline pixel 46 in a vertical direction is used when extracting the ruled line 40. However, when extracting the ruled line 40 that inclines as shown in FIG. 9, an angle θ of a tangential direction 42 to a horizontal direction 45 needs to be obtained, and distances Δx and Δy need to be obtained from Equations (1) and (2):Δx=d sin θ  (1)Δy=d cos θ  (2)
Then, the pixel value at the coordinates (Δx, Δy), which is a real value (a result of a floating-point arithmetic operation by a computer), is calculated from a pixel value of the original image, which is a discrete value.
FIG. 10 is a schematic diagram for explaining an example in which a false ruled line is extracted when a process for extracting a ruled line is performed on a halftone area. When a multi-value original image is read by a scanner and the read image is partly enlarged as shown in FIG. 10, each pixel is expressed by a pixel value (i.e., brightness). This area originally has no ruled line. However, when the area is binarized with a threshold of 85, continuous pixels in the horizontal direction are extracted as a false ruled line as shown in FIG. 10. If a false ruled line is extracted from a multi-value image (i.e., over-extraction is caused), the image quality is degraded.